package com.ozero1st;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;

public class VenusActivity extends Activity {
        private GridView gvMenu;
        private int[] picId = {
                        R.drawable.b1,R.drawable.b2,R.drawable.b3,
                        R.drawable.b4,R.drawable.b5,R.drawable.b6
        };
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        gvMenu = (GridView)findViewById(R.id.gridView1);
                gvMenu.setAdapter(new ImageAdapter(this));
                
                gvMenu.setOnItemClickListener(new OnItemClickListener(){

                        public void onItemClick(AdapterView<?> arg0, View v, int position,
                                        long id) {
                                  Intent myIntent = null;
                           if(position == 0){
                               myIntent = new Intent(v.getContext(), type1.class);
                           }
                           if(position == 1){
                               myIntent = new Intent(v.getContext(), type2.class);
                           }
                           if(position ==2){
                               myIntent = new Intent(v.getContext(), type3.class);
                           }
                           if(position ==3){
                               myIntent = new Intent(v.getContext(), type4.class);
                           }
                           if(position ==4){
                               myIntent = new Intent(v.getContext(), type5.class);
                           }
                           if(position ==5){
                               myIntent = new Intent(v.getContext(), type6.class);
                           }
                           startActivity(myIntent);             
                                // TODO Auto-generated method stub
                        }});
    }
    
    public class ImageAdapter extends BaseAdapter{
                private Context context;
                
                public ImageAdapter(Context c){
                        context = c;
                }
                
                public int getCount() {
                        // TODO Auto-generated method stub
                        return picId.length;
                }

                public Object getItem(int arg0) {
                        // TODO Auto-generated method stub
                        return null;
                }

                public long getItemId(int arg0) {
                        // TODO Auto-generated method stub
                        return 0;
                }

                public View getView(int position, View convertView, ViewGroup parent) {
                         View v;
                                        if(convertView==null){
                                                
                                        LayoutInflater li = getLayoutInflater();
                                        v = li.inflate(R.layout.dishow, null);
                                        
                                        //TextView tv = (TextView)v.findViewById(R.id.txtGv);
                                //tv.setText(text[position]);
                                
                                ImageView iv = (ImageView)v.findViewById(R.id.imageView1);                
                                iv.setImageResource(picId[position]);
                                iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
                                iv.setPadding(5, 5, 5, 5);
                               
                                
                                //imageView = new ImageView(context);
                                        //imageView.setLayoutParams(new GridView.LayoutParams(100,100));
                                        //imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                                        //imageView.setPadding(5, 5, 5, 5);
                                        //imageView.setImageResource(picId[position]);
                                    }
                                            else
                                            {
                                                v = convertView;
                                            }
                         return v;
                        }               
        }
}